package com.scqkxx.gamebox.activity.activities.view;

import android.content.Context;
import android.support.v7.widget.RecyclerView;

import com.bumptech.glide.Glide;

/**
 * Created by admin on 2018/8/14. 14点27分
 * name: 唐师
 * 用途： Glide 在滑动过程中停止加载, 停止状态开启加载
 */

public class ImageAutoLoadScrollListener extends RecyclerView.OnScrollListener {
    private Context mContext;

    public ImageAutoLoadScrollListener(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);
    }

    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);
        if (newState == RecyclerView.SCROLL_STATE_IDLE) {
            Glide.with(mContext).resumeRequests();
        }else {
            Glide.with(mContext).pauseRequests();
        }
    }
}
